//
//  AwayEventViewCell.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/16.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "AwayEventViewCell.h"
#import "DetailMatchEventModel.h"

@interface  AwayEventViewCell ()

@property(nonatomic,strong)UILabel *awayTimeLabel;
@property(nonatomic,strong)UIImageView *eventTypeImageView;
@property(nonatomic,strong)UILabel *whopeople;
@end

@implementation AwayEventViewCell






-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        CGFloat partHeight = 35;
        CGFloat timeWidth = kScreenIp6(60);
        
        
        //客队
        self.awayTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenWidth - timeWidth) / 2, 0, timeWidth, partHeight)];
        self.awayTimeLabel.textAlignment = NSTextAlignmentCenter;
        self.awayTimeLabel.font = [UIFont systemFontOfSize:14];
        
        [self.contentView addSubview:_awayTimeLabel];
        
        
        //类型
        
        self.eventTypeImageView =  [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.awayTimeLabel.frame) + kScreenIp6(10), (partHeight - kScreenIp6(20)) / 2, kScreenIp6(20), kScreenIp6(20))];
        self.eventTypeImageView.image = [UIImage imageNamed:@"yellow"];
        
        [self.contentView addSubview:_eventTypeImageView];
        
        
        
        //哪个人
        self.whopeople = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.eventTypeImageView.frame) + kScreenIp6(10), 0, (kScreenWidth - timeWidth) / 2 - kScreenIp6(50), partHeight)];
        self.whopeople.font = [UIFont systemFontOfSize:14];
        self.whopeople.textAlignment = NSTextAlignmentCenter;
        self.whopeople.adjustsFontSizeToFitWidth = YES;
        
        [self.contentView addSubview:_whopeople];
        
        
        //线
        UIView *footLineView = [[UIView  alloc]initWithFrame:CGRectMake( 0, partHeight, kScreenWidth, 0.5)];
        
        footLineView.backgroundColor = [UIColor colorWithWhite:0.699 alpha:1.000];
        
        [self.contentView addSubview:footLineView];
        
        // 设置 cell 点击没有变化
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    return self;
}


//
//1入球
//2 红牌
//3黄牌
//9 两黄变红
//11换人
//

-(void)setCellValue:(DetailMatchEventModel*)model
{
    switch ([model.ballType intValue])
    {
        case 1://入球
            self.eventTypeImageView.image = [UIImage imageNamed:@"goal_icon@2x"];
            break;
            
        case 2://红牌
            self.eventTypeImageView.image = [UIImage imageNamed:@"red"];
            break;
            
        case 3://黄牌
            self.eventTypeImageView.image = [UIImage imageNamed:@"yellow"];
            break;
            
        case 7://点球
            self.eventTypeImageView.image = [UIImage imageNamed:@"penalty_kick_icon@2x"];
            break;
            
        case 9://两黄变红
            self.eventTypeImageView.image = [UIImage imageNamed:@"yellowToRed"];
            break;
            
        case 11://换人
            self.eventTypeImageView.image = [UIImage imageNamed:@"huanren"];
            break;
            
        default:
            break;
    }
    
   if(model.people !=nil)
   {
       self.whopeople.text = model.people;
   }
    
    
     NSString *timeText =[NSString stringWithFormat:@"%@'",model.time];
    self.awayTimeLabel.text = timeText;
    
    
}


@end
